package com.ruoyi.activiti.controller;

import com.ruoyi.activiti.domain.ProcessDept;
import com.ruoyi.activiti.domain.ProcessRole;
import com.ruoyi.activiti.domain.ProcessUser;
import com.ruoyi.activiti.service.ProcessDeptService;
import com.ruoyi.activiti.service.ProcessRoleService;
import com.ruoyi.activiti.service.ProcessUserService;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("自定义流程引擎")
@RestController
@RequestMapping("/custom/process/user")
@AllArgsConstructor
public class ProcessUserController {
    @Autowired
    private ProcessUserService processUserService;
    @Autowired
    private ProcessRoleService processRoleService;
    @Autowired
    private ProcessDeptService processDeptService;
    @ApiOperation("通过用户名查询用户列表")
    @GetMapping("queryUserByName")
    public AjaxResult queryUserByName(String userName){
        List<ProcessUser> userList = processUserService.queryByName(userName);
        return AjaxResult.success(userList);
    }
    @ApiOperation("通过角色名查询角色列表")
    @GetMapping("queryRoleByName")
    public AjaxResult queryRoleByName(String roleName){
        List<ProcessRole> roleList = processRoleService.queryByName(roleName);
        return AjaxResult.success(roleList);
    }
    @ApiOperation("通过部门名查询部门列表")
    @GetMapping("queryDeptByName")
    public AjaxResult queryDeptByName(String deptName){
        List<ProcessDept> deptList = processDeptService.queryByName(deptName);
        return AjaxResult.success(deptList);
    }
}
